﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mogre;

namespace ProjetSMA.View.Mogre
{
    public class Field3D : Element3D
    {
        public Field3D(Model.Element par_item, SceneManager par_smngr, string par_name)
            : base(par_item, par_smngr, par_name)
        {
            Plane plane;
            plane.normal = Vector3.UNIT_Y;
            plane.d = 100;

            MeshManager.Singleton.CreatePlane("Myplane_field",
                  ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, plane,
                  20f, 20f, 10, 10, true, 1, 1, 1, Vector3.UNIT_Z);
        }

        public override void Initialisation()
        {
            m_entity = m_scene_mngr.CreateEntity(m_name, "cube.mesh");
           // m_entity_bis = m_scene_mngr.CreateEntity(m_name + "_bis", "cube.mesh");
            m_entity_bis = m_scene_mngr.CreateEntity(m_name + "_bis", "Myplane_field");

            m_node = m_scene_mngr.RootSceneNode.CreateChildSceneNode(m_name);
            m_node_bis = m_scene_mngr.RootSceneNode.CreateChildSceneNode(m_name + "_bis");

            m_node.Position = new Vector3(m_position.x, m_position.y + m_coef * m_height_item, m_position.z);
            m_node.Scale(0.2f, 0.2f, 0.2f);

           
            // grass
            m_node_bis.Position = m_node.Position + new Vector3(0, 111.5f, 0);

          

            m_entity.SetMaterialName("Examples/ElementField3D");
            m_entity_bis.SetMaterialName("Examples/ElementField3DBis");

            m_entity_bis.CastShadows = false;
            m_entity.CastShadows = false;

            m_node.AttachObject(m_entity);
            m_node_bis.AttachObject(m_entity_bis);

           
        }

        public void DefaultTexture()
        {
            m_entity_bis.SetMaterialName("Examples/ElementField3DBis");
        }
    }
}
